﻿using System;
using System.Collections.Generic;
using Color = System.Drawing.Color;
using SwinGame;

namespace Gundam_2._0_Alpha.src
{
    public class BasicShot:CharDrawAction
    {
        private const int h = 3;
        private const float chanceToStun = 0.05f;
        private int w = 0, startPosX, startPosY;
        private int minDamage;

        public BasicShot(Character c, bool persistant, int row, int colEnd, int count, int lockoutLevel, int minDamage)
            : base(c, persistant, row, colEnd, count, lockoutLevel)
        {
            this.minDamage = minDamage;
        }

        public override void DoAction(GameController gc)
        {
            if (!IsActive)
            {
                IsActive = true;
                c.GlobalLockout = true;
                GlobalConst.Utils.ActivateAnimationRow(c.ObjectSprite, row + c.offSetSpriteRow(), colEnd, count);
            }

            if (w == 0)
            {
                startPosX = (int)c.ObjectSprite.X + c.ShootOffsetX();
                startPosY = (int)c.ObjectSprite.Y + c.ShootOffsetY;
            }
           
            w += 50*c.DirectionMultiplier;

            GlobalConst.DmgCheck.CheckDamage(gc.GameStages.Peek().CharList, c, false, minDamage, gc, startPosX, startPosY, w, h, true,0.1f);

            if ((w >= 500 || w <= -500) || (c.ObjectSprite.CurrentCell >= ((c.offSetSpriteRow() + row) * c.ObjectSprite.Columns + colEnd) - 1))              
                Reset(gc);
        }

        public override void Draw()
        {
            Graphics.FillRectangle(Color.DeepPink, startPosX, startPosY, w, h);
        }

        public override void Reset(GameController gc)
        {
            w = 0;
            IsActive = false;
            c.LockoutTiers[LockoutLevel] = false;
            c.GlobalLockout = false;
            GlobalConst.Utils.ActivateAnimationRow(c.ObjectSprite, c.offSetSpriteRow(), GlobalConst.DefaultColEnd, GlobalConst.DefaultFPC);
        }
    }
}
